<template>
	<view class="dingdan">
		<view class="header">
			<view @click="navtab1(-1)" :class="{'on':navIndex1==-1}" class="nav1">全部</view>
			<view @click="navtab1(2)" :class="{'on':navIndex1==2}"  class="nav1">待核销</view>
			<view @click="navtab1(4)" :class="{'on':navIndex1==4}"  class="nav1">已完成</view>
		</view>
		<view class="list">
			<view class="list_con" v-for="item in list" :key="item.id">
				<view class="top" @click="details(item.id)">
					<view>订单编号：{{item.orderNumber}}</view>
					<view class="state">{{item.statusTitle}}</view>
				</view>
				
				<view  class="list_box" v-for="items in item.children" :key="items.id">
					<view class="list_">
						<view class="l_img"><image class="img" lazy-load :src="items.imgSrc" mode="aspectFill"></image></view>
						<view class="r_box">
							<view class="h6">{{items.goodName}}</view>
							<view class="dizhi">
								<view class="money">{{items.goodPrice}}</view>
								<view>X{{items.goodNum}}</view>
							</view>
						</view>
					</view>
				</view>
				
				<view class="yunfei">共计{{item.allNum}}件商品，合计<image class="coin" src="../../static/images/coin.png" mode=""></image><text class="text" style="font-size: 36rpx;">{{item.allPrice}}</text></view>
				<view class="top" style="height:120rpx;display: block;">
					<view>自提店铺：{{item.shopTitle}}</view>
					<view>核销码：{{item.logCode}}</view>
					<view>联系方式：{{item.pickName}}--{{item.pickPhone}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				navIndex1:-1,
				list:[],
				p:1,
				userinfo:[],
				from:''
			}
		},
		onLoad(options) {
			this.from = options.from;
			uni.setNavigationBarTitle({
			    title: '我的订单'
			});
			
			this.navIndex1=options.type;
			this.userinfo=uni.getStorageSync('user');
			this.getinfo();
		},
		methods:{
			copynum(str){
				uni.setClipboardData({
				    data: str,
				    success: function () {
				        uni.showToast({
				        	title: '复制成功',
				        	icon: 'none'
				        })
				    }
				})
			},
			navtab1(n){
				this.p=1;
				this.navIndex1 = n
				this.list=[];
				this.getinfo();
			},
			getinfo(){
				if(this.from == 'sp'){
					var that=this;
					this.$http.get('mallshop/getMyOrder',{type:that.navIndex1,page:that.p,logType:2}).
					then(function (response) {
						that.list=that.list.concat(response.data.orderlist);
						that.p++;
					}).catch(function (error) {
						console.log(error);
					});
				}else{
					var that=this;
					this.$http.get('order/getMyOrder',{type:that.navIndex1,page:that.p,logType:2}).
					then(function (response) {
						that.list=that.list.concat(response.data.orderlist);
						that.p++;
					}).catch(function (error) {
						console.log(error);
					});
				}
				
			}
		},
		//加载更多
		onReachBottom() {
			var that=this;
			that.getinfo();
		}
	}
</script>
<style>
	page{
		background-color: #f7f7f7;
	}
</style>

<style scoped lang="scss">
	.coin{
		width:50rpx;
		height:50rpx;
	}
	.dingdan{
		padding-bottom: 300rpx;
		.header{
			width: 100%;
			background-color: #ffffff;
			position: fixed;
			left: 0;
			top: (var(--window-top) +0rpx);
			height: 100rpx;
			align-items: center;
			display: flex;
			z-index: 5;
			border-bottom: 1px solid #F7F7F7;
			.nav1{
				font-size: 30rpx;
				color: #a5a5a5;
				padding: 0 33rpx;
			}
			.on{
				position: relative;
				color: #284179;
				&:after{
					position: absolute;
					content: "";
					width: 30%;
					height: 2px;
					background-color: #284179;
					left: 33%;
					top: 66rpx;
				}
			}
		}
		.list{
			position: relative;
			top: 120rpx;
			.list_con{
				margin-top: 20rpx;
				padding: 0 20rpx 20rpx;
				background-color: #FFFFFF;
				&:first-child{
					margin: 0;
				}
				.top{
					height: 80rpx;
					align-items: center;
					display: flex;
					justify-content: space-between;
					color: #a5a5a5;
					font-size: 26rpx;
					border-bottom: 1px solid #e5e5e5;
					.state{
						color: #454545;
					}
					.link{
						color: #284179;
					}
				}
				.list_box{
					.list_{
						padding: 40rpx 0;
						display: flex;
						.l_img{
							width: 250rpx;
							height: 200rpx;
							.img{
								display: block;
								width: 100%;
								height: 100%;
								border-radius: 3px;
							}
						}
						.r_box{
							position: relative;
							margin-left: 20rpx;
							.h6{
								padding-top: 20rpx;
								text-align:justify;
								width: 430rpx;
								font-size: 30rpx;
								color: #454545;
								white-space: nowrap;
								text-overflow: ellipsis; 
								overflow : hidden;
							}
						}
						.dizhi{
							width: 430rpx;
							position: absolute;
							height: 40rpx;
							align-items: center;
							bottom: 20rpx;
							display: flex;
							justify-content: space-between;
							color: #a5a5a5;
							font-size: 28rpx;
							.money{
								color: #a5a5a5;
								font-size: 32rpx;
								.text{
									font-size: 28rpx;
								}
							}
						}
					}
				}
				.yunfei{
					height: 50rpx;
					align-items: center;
					display: flex;
					justify-content: flex-end;
					font-size: 30rpx;
					color: #363636;
					.text{
						color: #284179;
					}
				}
				.btn{
					padding: 40rpx 0 20rpx;
					display: flex;
					justify-content: flex-end;
					height: 54rpx;
					align-items: center;
					.to_pingjia{
						margin-right: 20rpx;
						height: 54rpx;
						width: 140rpx;
						text-align: center;
						line-height: 54rpx;
						border-radius: 3px;
						background-color: #284179;
						font-size: 26rpx;
						color: #FFFFFF;
					}
					.qx_btn{
						margin-right: 20rpx;
						height: 54rpx;
						width: 140rpx;
						text-align: center;
						line-height: 54rpx;
						border-radius: 5px;
						border: 1px solid #bfbfbf;
						font-size: 26rpx;
						box-sizing: border-box;
						color: #bfbfbf;
					}
				}
			}
		}
	}
.copynum{
	margin-right: 20rpx;
	height: 54rpx;
	width: 140rpx;
	text-align: center;
	line-height: 54rpx;
	border-radius: 5px;
	border: 1px solid #bfbfbf;
	font-size: 26rpx;
}
</style>
